package com.visec.hdy.transmission.socket.config;

import java.util.Map;

import com.visec.hdy.config.ParameterCV;
import com.visec.hdy.utils.ParameterHandle;

public class SSocketModelCV implements ParameterCV<SocketModel> {
	private String ip = "localhost";
	private int port = 4401;
	private String charset = "utf-8";
	private int bufferSize = 2048;

	/**
	 * allIp=ip;allPort=port;ip=sip;port=sport;charset=scharset;
	 */
	@Override
	public void setParams(Map<String, String> m) {
		// TODO Auto-generated method stub
		if (m.containsKey("-sip"))
			ip = ParameterHandle.testIp(m.get("-sip"));
		if (m.containsKey("-sport"))
			port = Integer.parseInt(ParameterHandle.testNumber(m.get("-sport")));
		if (m.containsKey("-scharset"))
			charset = m.get("-scharset");
		if (m.containsKey("-sbufferSize"))
			bufferSize = Integer.parseInt(m.get("-sbufferSize"));
	}

	@Override
	public SocketModel getParameter() {
		// TODO Auto-generated method stub
		return new SocketModel(ip, port, charset, bufferSize);
	}

}
